package cn.com.bonc.khjy.service;


import cn.com.bonc.khjy.date.dao.dataSource1.CommonDao1;
import cn.com.bonc.khjy.date.dao.dataSource3.CommonDao3;
import cn.com.bonc.khjy.date.dao.dataSource4.CommonDao4;
import cn.com.bonc.khjy.utils.JacksonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CommonService {

    private Logger logger = LoggerFactory.getLogger(CommonService.class);

    @Autowired
    private CommonDao1 dao1;

    @Autowired
    private CommonDao3 dao3;

    @Autowired
    private CommonDao4 dao4;

    public List<String> getTopic() {
         return dao1.getTopic();

    }

    public String getContactorName(String contactorId){
        return dao3.getContactorName(contactorId);
    }

    public String getProductName(String productId){
        return dao4.getProductName(productId);
    }

    public List<Map<String, Object>> getBaseActivityList(Integer pageNum, Integer pageSize, String activityName) {
        return dao1.getBaseActivityList(pageNum,pageSize,activityName);
    }

    public Integer getCustomerCount(String activity_code) {
            String customerCount = dao1.getCustomerCount(activity_code);
            Map<String, ?> result = JacksonMapper.INSTANCE.readJsonToObject(customerCount);
            int count  = Integer.parseInt(result.get("targetCustomerAmount").toString());
            return count;
    }

    public Map<String, Object> getBaseActivityInfo(String activityCode) {
        return dao1.getBaseActivityInfo(activityCode);
    }

    public List<Map<String, Object>> getSubCustomerGroupInfo(String activityCode) {
        return dao1.getSubCustomerGroupInfo(activityCode);
    }

    public String getStrategyNodeId(String nodeId) {
        return dao1.getStrategyNodeId(nodeId);
    }

    public String getStrategyInfo(String strategyNodeId) {
        return dao1.getStrategyInfo(strategyNodeId);
    }

    public String getChannelNodeId(String strategyNodeId) {
        return dao1.getChannelNodeId(strategyNodeId);
    }

    public String getChannelInfo(String channelNodeId) {
        return dao1.getChannelInfo(channelNodeId);
    }

    public String getCustomerGroupInfo(String activityCode) {
        return dao1.getCustomerGroupInfo(activityCode);
    }


    public List<String> getAllContactorId() {
        return dao3.getAllContactorId();
    }

    public List<String> getAllContactorTopic(){
        return dao3.getAllContactorTopic();
    }
}
